<template>
  <div class="list">
    <!-- 头部 -->
    <div class="yuyue">
      <van-nav-bar title="预约挂号">
        <template #left>
          <van-icon
            name="arrow-left"
            :size="20"
            color="#333333"
            @click="hanclick"
          />
        </template>
      </van-nav-bar>
      <!-- 搜索 -->
      <van-search v-model="value" placeholder="搜索医院或医生">
        <template #left-icon>
          <van-icon class-prefix="iconfont" name="extra" />
        </template>
      </van-search>
    </div>
    <!-- 照片 -->
    <div class="price">
      <img src="../assets/img/banner.png" alt="" />
    </div>
    <!-- 列表渲染 -->
    <ul>
      <li v-for="item in hospital" :key="item._id">
        <div class="le">
          <img :src="item.imgurl" alt="" />
        </div>
        <div class="ri">
          <div class="top">{{ item.name }}</div>
          <div class="mi">
            <span class="span1">特色科室：</span>
            <span class="span2">{{ item.characteristic[0] }}</span>
            <span class="span3">{{ item.characteristic[1] }}</span>
          </div>
          <div class="bot">
            <div class="left">
              <img src="../assets/img/icon8.png" alt="" />
              <span>{{ item.position }}</span>
            </div>
            <div class="right">
              <img src="../assets/img/icon9.png" alt="" />
              <span>{{ item.level }}</span>
            </div>
          </div>
        </div>
      </li>
    </ul>
    <p class="bottom">已经到底了哦</p>
  </div>
</template>
<script>
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { ref, computed, onMounted } from "vue";

export default {
  setup() {
    const router = useRouter();
    const store = useStore();
    const value = ref("");

    //计算属性拿取vuex里面的数据
    const hospital = computed(() => store.state.hospital);

    onMounted(() => {
      sethospital();
    });
    const hanclick = () => {
      router.push("/home");
    };

    const sethospital = () => store.dispatch("getHospital");
    // setTimeout(() => {
    //   console.log(hospital.value);
    // }, 1000);

    return {
      hospital,
      sethospital,
      hanclick,
      value,
    };
  },
};
</script>
<style lang="less">
.list {
  position: relative;
  .bottom {
    text-align: center;
    line-height: 50px;
    font-size: 14px;
    color: #666666;
  }
  background: white;
  @font-face {
    font-family: "iconfont";
    src: url("../assets/font/iconfont.ttf") format("truetype");
  }

  .yuyue {
    width: 100%;
    z-index: 100;
    background: white;
    position: fixed;
    left: 0;
    top: 0;
  }
  .price {
    width: 100%;
    margin-top: 90px;
    font-size: 0;
    img {
      width: 100%;
      // height: 91px;
    }
  }

  .iconfont {
    font-family: "iconfont" !important;
    font-size: 18px;
    font-style: normal;
    font-weight: 600;
    opacity: 0.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .iconfont-extra::before {
    content: "\e62d";
  }
  .van-nav-bar__title {
    width: 75px;
    height: 18px;
    font-weight: 400;
    line-height: 18px;
  }
  .van-search {
    width: 100%;
    height: 37px;
    background: #f4f5fa;
    border-radius: 18px;
    margin: 10px auto;
  }
  .van-field__control {
    font-size: 16px;
    font-weight: 400;
    color: #666666;
  }
  li {
    padding: 17px 0 17px 15px;
    border-bottom: 1px solid #edefee;
    display: flex;
    .le {
      margin-right: 8px;
      width: 118px;
      height: 85px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .ri {
      height: 85px;
      padding-top: 6px 0 0 4px;
      .top {
        // width: 100px;
        height: 13px;
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        line-height: 18px;
        margin-bottom: 20px;
      }
      .mi {
        margin-bottom: 5px;
        width: 195px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        span {
          display: inline-block;
        }
        .span1 {
          font-size: 1px;
          font-weight: 400;
          color: #666666;
          margin-right: 2px;
        }
        .span2 {
          width: 55px;
          height: 20px;
          border: 1px solid #bababa;
          border-radius: 8px;
          font-size: 11px;
          font-weight: 400;
          color: #888888;
          line-height: 18px;
          text-align: center;
        }
        .span3 {
          text-align: center;
          width: 75px;
          height: 20px;
          border: 1px solid #999999;
          border-radius: 8px;
          font-size: 12px;
          font-weight: 400;
          color: #666666;
          line-height: 18px;
          opacity: 0.4;
        }
      }
      .bot {
        width: 200px;
        display: flex;
        justify-content: space-between;
        .left {
          display: flex;
          align-items: center;
          img {
            width: 19px;
            height: 24px;
          }
          span {
            display: inline-block;
            font-size: 11px;
            font-weight: 400;
            color: #999999;
          }
        }
        .right {
          display: flex;
          align-items: center;
          font-size: 11px;
          font-weight: 400;
          color: #666666;
        }
      }
    }
  }
}
</style>
